package com.mh.study.jackson.annotations;

import com.fasterxml.jackson.annotation.JsonBackReference;

import java.util.ArrayList;
import java.util.List;

/**
 * @author meng.han
 * @since 2021-11-26
 */
public class UserWithRef {

    public int id;
    public String name;

    @JsonBackReference
    public List<ItemWithRef> userItems;

    public void addItem(ItemWithRef item) {
        userItems.add(item);
    }

    public UserWithRef() {
    }

    public UserWithRef(int id, String name) {
        this.id = id;
        this.name = name;
        this.userItems = new ArrayList<>();
    }
}
